package service;

import dao.UserDao;
import model.User;

import java.sql.SQLException;

public class UserService {
    private UserDao uDao = new UserDao();
    public boolean register(User user){
        try {
            if(uDao.isUsernameExist(user.getName()))
                return false;
            uDao.insert(user);
            return true;
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return false;
    }
    public boolean login(String name,String password){
        try {
            if(uDao.isUserNamePasswordExist(name,password)){
                return true;
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return false;
    }
}
